Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async validate(value, options, { field, entity }) {
// If it's an existing entity, most likely it already has all the required values.
// We do this fast check to be sure, and skip validation if value is already set.
const attribute = entity.getAttribute(field.fieldId);
if (attribute && (await attribute.getValue())) {
return;
}
await validation.validate(value, "required");
}
},
validate: (value, validator) => {
const lteValue = validator.settings.value;
if (typeof lteValue !== "undefined") {
return validation.validate(value, `lte:${lteValue}`);
}
}
}
async validate(value, { min }) {
await validation.validate(value, `minLength:${min}`);
}
}
validate: value => {
return validation.validate(value, "required");
}
}
validate: value => {
return validation.validate(value, "required");
}
}
validate: (value, validator) => {
const minLengthValue = validator.settings.value;
if (typeof minLengthValue !== "undefined") {
return validation.validate(value, `minLength:${minLengthValue}`);
}
}
}
validate: (value, validator) => {
const gteValue = validator.settings.value;
if (typeof gteValue !== "undefined") {
return validation.validate(value, `gte:${gteValue}`);
}
}
}
validate: (value, validator) => {
const maxLengthValue = validator.settings.value;
if (typeof maxLengthValue !== "undefined") {
return validation.validate(value, `maxLength:${maxLengthValue}`);
}
}
}
validate: (value, validator) => {
const values = validator.settings.values;
if (Array.isArray(values)) {
return validation.validate(value, `in:${values.join(":")}`);
}
}
}