// Checks if:
// 
// • A given expression is valid.
// 
// • A number is correct according to the locale.
//
// Parameters:
//
// ◾ expr   -   Expression to check.
//
542538
func (obj *Doc) CheckNumberOrExpression(ctx context.Context, expr string) (string, []*NxRange, error) {
	result := &struct {
		ErrorMsg string	`json:"qErrorMsg"`
		BadFieldNames []*NxRange	`json:"qBadFieldNames"`
	} {}
	err := obj.rpc(ctx, "CheckNumberOrExpression", result, expr)
	return result.ErrorMsg, result.BadFieldNames, err 
}
366665
func Valid(cpf string) bool {
	isValid, err := AssertValid(cpf)
	if err != nil {
		return false
	}
	return isValid
}
1006250
func If(conditional BoolExpression,
	trueExpression Expression,
	falseExpression Expression) Expression {
	return &ifExpression{
		conditional:     conditional,
		trueExpression:  trueExpression,
		falseExpression: falseExpression,
	}
}
21454
func (verification *TokenVerification) Valid() bool {
	if verification.HTTPResponse.StatusCode == 200 && verification.Token == "is valid" {
		return true
	}

	return false
}
799527
func Expr(expr syntax.Expr, isPredeclared, isUniversal func(name string) bool) ([]*syntax.Ident, error) {
	r := newResolver(isPredeclared, isUniversal)
	r.expr(expr)
	r.env.resolveLocalUses()
	r.resolveNonLocalUses(r.env) // globals & universals
	if len(r.errors) > 0 {
		return nil, r.errors
	}
	return r.moduleLocals, nil
}
978859
func ValidateMatchAll(patterns ...string) FieldValidatorFunc {
	prx := make([]*regexp.Regexp, len(patterns))

	for i, rxs := range patterns {
		prx[i] = regexp.MustCompile(rxs)
	}

	return func(value interface{}) error {
		for _, rx := range prx {
			if !rx.MatchString(typeutil.String(value)) {
				return fmt.Errorf("Value does not match pattern %q", rx.String())
			}
		}

		return nil
	}
}
746706
func (r *SignonResponse) Valid(version ofxVersion) (bool, error) {
	if len(r.Language) != 3 {
		return false, fmt.Errorf("SONRS>LANGUAGE invalid length: \"%s\"", r.Language)
	}
	return r.Status.Valid()
}
302255
func Error(t testing.TB, expr interface{}, args ...interface{}) {
	if IsNil(expr) { // 空值，必定没有错误
		assert(t, false, args, []interface{}{"Error 失败，实际值为 Nil：[%T]", expr})
		return
	}

	_, ok := expr.(error)
	assert(t, ok, args, []interface{}{"Error 失败，实际类型为[%T]", expr})
}
493570
func (r *Result) IsValid() bool {
	if r == nil {
		return true
	}
	return len(r.Errors) == 0
}
103185
func like(lhs Expression, val interface{}) BooleanExpression {
	return checkLikeExp(LIKE_OP, lhs, val, false)
}
1335796
func (p *Parser) UnaryExpression() bool {

	c := p.PeekByte()

	if IsLetter(rune(c)) {
		p.ev.Add(TypePath)
		p.ev.Inc()
		p.Path()
		p.ev.Dec()
		return true
	}

	b, ok := p.Number()
	if ok {
		p.ev.Add(b)
		return true
	}

	b, ok, _ = p.Quoted(0)
	if ok {
		p.ev.Add(TypeString)
		p.ev.Inc()
		p.ev.Add(b)
		p.ev.Dec()
		return true
	}

	b, ok = p.Operator()
	if ok {
		p.ev.Add(b)
	}

	if p.PeekByte() == '(' {
		p.Byte() // Consume the '('
		p.ev.Add(TypeGroup)
		p.ev.Inc()
		p.Space()
		p.Expression()
		p.Space()
		p.ev.Dec()

		if p.PeekByte() != ')' {
			return false
		}
		p.Byte() // Consume the ')'
		return true
	}

	return p.Path()
}
152980
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
	return Regexp(a.t, rx, str, msgAndArgs...)
}
355148
func (t *typeChecker) AcceptComparison(v tree.Comparison) {
	if !t.expectBoolean {
		t.result = fmt.Errorf("expected numeric expression but found: %s", tree.ExpressionString(v))
		return
	}

	// This language only accepts comparisons between numeric values, so we implement that here
	res := either(
		typeCheckExpectingNumeric(v.Left),
		typeCheckExpectingNumeric(v.Right))
	if res != nil {
		t.result = res
	}
}
77561
func (i ContainsExpr) String() string {
	return fmt.Sprintf("contains(%v, %v)", i.Left, i.Right)
}
479750
func ValidLangCode(c string) bool {
	for d := range LangCodes {
		if c == d {
			return true
		}
	}
	return false
}
210601
func IsValid(expr string) bool {
	_, err := parse(expr, &match{})
	return err == nil
}
938029
func parseExpression(expr string) (expression, error) {
	var pos int
	prefix, regex, not := false, false, false
	res := expression{}

	// scan up to operator to get key
FIND_OPERATOR:
	for ; pos < len(expr); pos++ {
		switch expr[pos] {
		case '=':
			break FIND_OPERATOR
		case '!':
			not = true
			break FIND_OPERATOR
		case '^':
			prefix = true
			break FIND_OPERATOR
		case ';':
			return res, errInvalidQuery
		}
	}

	// key must not be empty
	if pos == 0 {
		return res, errInvalidQuery
	}

	res.key = expr[:pos]

	// shift over the !/^ characters
	if not || prefix {
		pos++
	}

	if len(expr) <= pos || expr[pos] != '=' {
		return res, errInvalidQuery
	}
	pos++

	if len(expr) > pos && expr[pos] == '~' {
		// ^=~ is not a valid operator
		if prefix {
			return res, errInvalidQuery
		}
		regex = true
		pos++
	}

	valuePos := pos
	for ; pos < len(expr); pos++ {
		// disallow ; in value
		if expr[pos] == 59 {
			return res, errInvalidQuery
		}
	}
	res.value = expr[valuePos:]

	// special key to match on tag instead of a value
	if res.key == "__tag" {
		// currently ! (not) queries on tags are not supported
		// and unlike normal queries a value must be set
		if not || len(res.value) == 0 {
			return res, errInvalidQuery
		}

		if regex {
			res.operator = MATCH_TAG
		} else if prefix {
			res.operator = PREFIX_TAG
		} else {
			// currently only match & prefix operator are supported on tag
			return res, errInvalidQuery
		}

		return res, nil
	}

	if not {
		if regex {
			res.operator = NOT_MATCH
		} else {
			res.operator = NOT_EQUAL
		}
	} else {
		if regex {
			res.operator = MATCH
		} else if prefix {
			res.operator = PREFIX
		} else {
			res.operator = EQUAL
		}
	}
	return res, nil
}