Skip to content

Instantly share code, notes, and snippets.

@rvantonder
Last active July 31, 2020 10:43
Show Gist options
  • Save rvantonder/c85b4a067234801a5fe3d7bd59fcb800 to your computer and use it in GitHub Desktop.
Save rvantonder/c85b4a067234801a5fe3d7bd59fcb800 to your computer and use it in GitHub Desktop.
[Email]
match="Email(:[field]),"
rewrite="+ email(:[field])"
[NoValidation]
match="NoValidation(:[field]),"
rewrite="+ [|NoValidation({field: :[field]})|]"
[StringNonEmpty]
match="StringNonEmpty(:[field]),"
rewrite="+ nonEmpty(:[field])"
[StringRegExp]
match="StringRegExp(:[field], :[matches]),"
rewrite="+ regExp(~matches=:[matches], :[field])"
[Custom]
match="Custom(:[field], :[predicate]),"
rewrite="+ custom(:[predicate] :[field])"
[FloatMin]
match="FloatMin(:[field], :[min]),"
rewrite="+ float(~min=:[min], :[field])"
[IntMin]
match="IntMin(:[field], :[min]),"
rewrite="+ int(~min=:[min], :[field])"
[StringMin]
match="StringMin(:[field], :[min]),"
rewrite="+ string(~min=:[min], :[field])"
[FloatMax]
match="FloatMax(:[field], :[max]),"
rewrite="+ float(~max=:[max], :[field])"
[IntMax]
match="IntMax(:[field], :[max]),"
rewrite="+ int(~max=:[max], :[field])"
[StringMax]
match="StringMax(:[field], :[max]),"
rewrite="+ string(~max=:[max], :[field])"
# open scope and rewrite [||]
[Validation-1]
match="Validation.Schema([|:[validators]|])"
rewrite="Validation.(Schema(:[validators]))"
# Remove trailing +
[Validation-2]
match="Validation.(Schema( + :[validator] + :[rest]))"
rewrite="Validation.(Schema(:[validator] + :[rest]))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment