volder is powerful Object schema validation lets you describe your data using a simple and readable schema and transform a value to match the requirements
import { Volder } from 'volder';
const personSchema = new Volder({
name:{ type: String, required: true, maxLength: 10, trim: true },
age: { type: Number, min: 18, sign: 'positive' }
})
const { valid, errors, value } = personSchema.validate({name: "max ", age: 19}); // we forget adding a validate function.
// { valid: true, errors: {}, value: {name: "max", age: 19}}
fix: email validation, first index contain letter , accept some symbols
src/lib/volder-types/email.js
export const Email = (input) => {
const regex = /^[\w.~!#$%&'*+-/=?^_`{|]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,6}$/;
const code = String(input).charCodeAt(0);
if (!(code > 64 && code < 91) && !(code > 96 && code < 123)) {
return false;
}
return regex.test(String(input))
};
fix volder publish to npm issue
volder comes with major things and feature to improve validation and simplify to the developer to complete here work with full patiant
change from importing Volder as defualt to be in an object
import { Volder } from 'volder';
fix nested schema issues
the clear and public release
features
add custom error message by doing array
const volderSchema = new Volder({
name:{
type:[String, 'type should be string']
})