Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds presence, absence validators, adds errors and tests * Refactor validator definitions, adds acceptance, exclusion * Return real validation error message via GraphQL * Adds inclusion validation * Adds `in` option for acceptance * Adds format and length validation * Adds numericality validation * Comments and usage examples for each validator * Adds allowNull, allowUndefined, allowEmptyString options to presence validator * Reorganize tests * Adds validateUniqueness() * Tests for validateUniqueness() * Rewrite mock to more generic style * No need to import PrismaClient to mock in tests * TYPESCRIPT * Type typo * Make all validators accept unknown types and worry about them inside each one * Comment typos * Adds validateWith() for custom validation function * Adds `model` as first argument of validateUniqueness, pass new instance of PrismaClient to callback function * validateWith takes no arguments but function * Humanize field names in error messages * Reverse order of field name and value * Don't modify field name case, just use what they gave us * Adds email, positive and negative validators * Tweak email validation, add tests * Removes humanize-string * Add $self and $scope to validateUniqueness() * Refactors errors, allows for substitutions in error messages * Use mustache syntax for error message interpolation * Make options object just options, move booleans to argument list * Update syntax to make label optional * Remove unused argument * Overload validateUniqueness() so that we can pass optional third parameter with message * Rename "directive" -> "recipe" * Adds RedwoodError, extend ServiceValidationError, allow RedwoodErrors through GraphQL * Fix check for allow list (must be instanceof) * Switch string interpolation to ${} to match dbAuth Co-authored-by: Rob Cameron <rob.cameron@fastmail.com> Co-authored-by: David Price <thedavid@thedavidprice.com>
- Loading branch information