How to use the validatorjs.useLang function in validatorjs

To help you get started, we’ve selected a few validatorjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dev-Snippets / java-snippets / js / declarative-validator / src / core / validatorjs.js View on Github external
// @flow
import type { ValidateResponse } from './types';
const Validator = require('validatorjs');
Validator.useLang('zh');

/**
 * Description 自定义校验规则,!本部分是使用了 validatorjs 作为内部实现
 * @param data
 * @param rules
 * @param customMessage
 * @return ValidateResponse
 */
export function validate(
  data: any,
  rules: {
    [string]: string | []
  },
  customMessage: {
    [string]: string
  } = undefined
github DefinitelyTyped / DefinitelyTyped / validatorjs / validatorjs-tests.ts View on Github external
validator.passes(() => {})

var fails: boolean = validator.fails() as boolean
validator.fails(() => {})

var check: boolean = validator.check()

var errors: Validator.Errors = validator.errors
var all: Validator.ValidationErrors = errors.all()
var error: Array = errors.get("foo")
var first: string | boolean = errors.first("foo")
var has: boolean = errors.has("foo")

Validator.setMessages("en", {})
var messages: Validator.ErrorMessages = Validator.getMessages("en")
Validator.useLang("en")
var lang: string = Validator.getDefaultLang()
Validator.setAttributeFormatter((attributes: any) => ({}))
Validator.stopOnError(true)
Validator.register("custom", () => {}, "error.custom")
Validator.registerAsync("custom", () => {}, "error.custom")
github vict-shevchenko / reactive-mobx-form / src / createForm.tsx View on Github external
export function configureValidatorjs(configParameters: IValidatorjsConfiguration): void {
	if (configParameters.language) {
		Validator.useLang(configParameters.language);
	}
	if (configParameters.setAttributeFormatter) {
		Validator.setAttributeFormatter(configParameters.setAttributeFormatter);
	}
}
github vict-shevchenko / reactive-mobx-form / src / createForm.tsx View on Github external
export function configureValidatorjs(configParameters: IValidatorjsConfiguration): void {
	if (configParameters.language) {
		Validator.useLang(configParameters.language);
	}
	if (configParameters.setAttributeFormatter) {
		Validator.setAttributeFormatter(configParameters.setAttributeFormatter);
	}
}