Skip to content

Custom validation for fields #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 24, 2017
Merged

Custom validation for fields #169

merged 6 commits into from
Mar 24, 2017

Conversation

icebob
Copy link
Member

@icebob icebob commented Mar 23, 2017

It is the implementation of #110 .

You can add custom validator messages for fields in schema.
Every validator function has a method locale. Parameter is an object of custom messages.

Example:

let schema = {
	fields: [
		{
			type: "input",
			inputType: "password",
			label: "Password",
			model: "password",
			min: 6,
			required: true,

			// String validator with custom error messages
			validator: validators.string.locale({ 
				fieldIsRequired: "The password is required!",
				textTooSmall: "Password must be at least {1} characters"
			})
		}
	]
}

Result:
image

@icebob icebob added this to the v2.0.0 milestone Mar 23, 2017
@icebob icebob merged commit 19d5e5a into master Mar 24, 2017
@icebob icebob deleted the custom-validation branch March 24, 2017 08:06
@icebob icebob mentioned this pull request Mar 29, 2017
5 tasks
@icebob
Copy link
Member Author

icebob commented Apr 4, 2017

Released in v2.0.0-beta6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant