Created
July 30, 2020 13:38
-
-
Save fakenickels/ebaf3724b6e321d51d5ad45497c51a68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for each and every validator | |
comby 'Email(:[field]),' '+ email(:[field])' .re -i | |
comby 'NoValidation(:[field]),' '+ [|NoValidation({field: :[field]})|]' .re -i | |
comby 'StringNonEmpty(:[field]),' '+ nonEmpty(:[field])' .re -i | |
comby 'StringRegExp(:[field], :[matches]),' '+ regExp(~matches=:[matches], :[field])' .re -i | |
comby 'Custom(:[field], :[predicate]),' '+ custom(:[predicate] :[field])' .re -i | |
comby 'FloatMin(:[field], :[min]),' '+ float(~min=:[min], :[field])' .re -i | |
comby 'IntMin(:[field], :[min]),' '+ int(~min=:[min], :[field])' .re -i | |
comby 'StringMin(:[field], :[min]),' '+ string(~min=:[min], :[field])' .re -i | |
comby 'FloatMax(:[field], :[max]),' '+ float(~max=:[max], :[field])' .re -i | |
comby 'IntMax(:[field], :[max]),' '+ int(~max=:[max], :[field])' .re -i | |
comby 'StringMax(:[field], :[max]),' '+ string(~max=:[max], :[field])' .re -i | |
# open scope and rewrite [||] | |
comby 'Validation.Schema([|:[validators]|])' 'Validation.(Schema(:[validators]))' .re -i | |
# Remove trailing + | |
comby 'Validation.(Schema( + :[validator] + :[rest]))' 'Validation.(Schema(:[validator] + :[rest]))' .re -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment