yup-extensions (WIP)
Some additional validation methods for yup
npm install yup-extensions
Part of the eigencode project.
Example
;; const val1 = ;const val2 = ;const val3 = ;
yup-extensions makes use of yup-universal-locale, so you can set default messages for these methods using yup's setLocale
method.
; ;
Included validation methods
string.mustNotContain(stringOrRegex, message?) - fails if the value contains the specified string, or matches the specified regex. The message is passed a match
parameter which is the matching string.
mixed.requriedStrict(message?) - fails if the value is missing, or null
, or an empty string, or a string containing only whitespace.
mixed.unique(selector?, message?) - only valid within an array, this ensures that this value does not appear in the same place in other entries of the array. This is determined by strict equality (a === b
) - a selector
function may be used to map the value to the value-to-be-compared. Important: for this validator to work, the validation context must be set to the data object to be validated:
const val = ; val