Skip to content

v2.0.0-beta6

Pre-release
Pre-release
Compare
Choose a tag to compare
@icebob icebob released this 04 Apr 07:42
· 355 commits to master since this release

New

Support async validators #171

let customAsyncValidator = function(value) {
	return new Promise((resolve, reject) => {
		setTimeout(() => {
			if (value)
				resolve();
			else
				resolve([ "Invalid value from async validator" ]);
		}, 1000);
	});
};

Schema:

{
	type: "input",
	inputType: "url",
	label: "URL",
	model: "website",
	validator: customAsyncValidator
}

Custom messages for validators #169

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

Ability to use string as name of validator by jmverges #167

You can set validator as string instead of Function.

{
	type: "input",
	inputType: "text",
	label: "Name",
	model: "name",
	min: 3,
	validator: "string"
}

This is a shorthand for VueFormGenerator.validators.string. It can be an Array of Strings too.

Fixes

  • fixed vue-multiselect customLabel handling by cristijora #159
  • fixed "TypeError: this.value.push is not a function" in checklist by lionel-bijaoui #156
  • ... other minor fixes.

Commits

  • 📦 build (dd33ea0)
  • #159 Fix customLabel function from multi-select field to work with object values (84d3e41)
  • #172 Sync model value with files from file upload input (4ac96e4)
  • checklist field now support array of string or array of objects (with name and value propertie (be09146)
  • radios field now support array of string or array of objects (with name and value properties) (0f48c30)
  • add .locale method to every validator (1dc7fb7)
  • Add a is-checked class to element where the input is checked to ease customisation. Add checklist (3facc08)
  • add example to dev (267073c)
  • add test for async validator (e9463c2)
  • bump version (8ced4af)
  • change input event to change on checlist field (e6a2b9a)
  • Change onChange trigger event from change to input for checklist (67a3659)
  • fix #174 (d939c95), closes #174
  • Fix a problem with value define but not an Array (190f67a)
  • fix double validator (7c6d658)
  • Fix error "TypeError: this.value.push is not a function" in checklist (c66b0e9)
  • fix lint (1f99ab6)
  • fix parameters of validators (d97c917)
  • Fix test to reflect changes (6126f25)
  • fix usage example in readme (596b302)
  • Fix validator messages interpolation (6b44e39)
  • Improve readme file. (846cf15)
  • Move some dependency to devDependency (b00e4bb)
  • Provides ability to use strings as validators (36c7829)
  • remove only from test (560d234)
  • simplify code (cd922ee)
  • support async (promised) validators #170 (d50a756)
  • update code language in readme (3ee0865)
  • Update the unit test to reflect the changes and test for the new behavior. Fix lint error. (1f6150f)
  • Update unit test for checklist (24eb17f)
  • Update unit test for radios (8a94e81)
  • Use this.$set instead of a direct assignation (4b7e118)