check-rule-mate (auto documentation + playground example)
Visual documentation of validation rules and schemas.
Schema: contactUs
| Field | Rule | Required | Cache |
|---|---|---|---|
| name | name | ✔ | ✔ |
| lastName | name | ✔ | ✔ |
| ✔ | off | ||
| emailConfirm | email--confirm | ✔ | off |
| phone | phone | optional | ✔ |
| subject | hasText | ✔ | ✔ |
| message | hasText | ✔ | ✔ |
Schema Test (Experimental)
Result:
Schema: customerCreation
| Field | Rule | Required | Cache |
|---|---|---|---|
| name | name | ✔ | ✔ |
| lastName | name | optional | ✔ |
| birthdate | date--age | ✔ | ✔ |
| cpf | cpf | ✔ | ✔ |
| ✔ | ✔ | ||
| phone | phone | ✔ | ✔ |
Schema Test (Experimental)
Result:
Schema: myAccount
| Field | Rule | Required | Cache |
|---|---|---|---|
| name | name | ✔ | ✔ |
| lastName | name | optional | ✔ |
| birthdate | date--age | ✔ | ✔ |
| cpf | cpf | ✔ | ✔ |
| ✔ | ✔ | ||
| emailConfirm | email--confirm | ✔ | ✔ |
| phone | phone | ✔ | ✔ |
Schema Test (Experimental)
Result:
Schema: nameSpecialValidationRules
| Field | Rule | Required | Cache |
|---|---|---|---|
| name | name | ✔ | ✔ |
| cellphone | phone | ✔ | ✔ |
| ✔ | ✔ |
Schema Test (Experimental)
Result:
Rule: name (myValidatorRules)
Used to validate names based if they have text or not.
Validation Flow
hasText
→
valid
Error Codes
- hasText common.hasText
Used by Schemas
- contactUs → name (name)
- contactUs → lastName (name)
- customerCreation → name (name)
- customerCreation → lastName (name)
- myAccount → name (name)
- myAccount → lastName (name)
- nameSpecialValidationRules → name (name)
Notes
You can add your special note here.
Rule: hasText (myValidatorRules)
Used to validate if a text field is not blank.
Validation Flow
hasText
→
valid
Error Codes
- hasText common.hasText
Used by Schemas
- contactUs → subject (hasText)
- contactUs → message (hasText)
Rule: email (myValidatorRules)
Used to validate email fields. Checking if hasText and if matches with a valid format for emails.
Validation Flow
regex
→
valid
Error Codes
- regex email.regex
Modifiers
confirm
Used to validate if email confirm fields are valid emails and matches with the primary email field.
regex
→
equals
→
valid
Error Codes
Used by Schemas
- contactUs → email (email)
- contactUs → emailConfirm (email--confirm)
- customerCreation → email (email)
- myAccount → email (email)
- myAccount → emailConfirm (email--confirm)
- nameSpecialValidationRules → email (email)
Notes
To use email confirm modifier use email--confirm
Rule: phone (myValidatorRules)
Checks if phone number has a valid format.
Validation Flow
regex
→
valid
Error Codes
- regex phone.regex
Used by Schemas
- contactUs → phone (phone)
- customerCreation → phone (phone)
- myAccount → phone (phone)
- nameSpecialValidationRules → cellphone (phone)
Notes
Only works for Brazilian's phone numbers
Rule: date (myValidatorRules)
Used to validate a date format in date or string fields
Validation Flow
regex
→
validDate
→
valid
Error Codes
Modifiers
Used by Schemas
- customerCreation → birthdate (date--age)
- myAccount → birthdate (date--age)
Notes
Can validate someone age based on birthdate through the date--age modifier
Rule: cpf (myValidatorRules)
Used to check if someone CPF is valid or not
Validation Flow
cpf
→
valid
Error Codes
- cpf cpf.cpf
Used by Schemas
- customerCreation → cpf (cpf)
- myAccount → cpf (cpf)
Notes
CPF is a ID document which only works in Brazil
Rule: name (nameSpecialValidationRules)
Validation Flow
nameSpecialValidation
→
valid
Error Codes
- nameSpecialValidation name.nameSpecialValidation
Used by Schemas
- contactUs → name (name)
- contactUs → lastName (name)
- customerCreation → name (name)
- customerCreation → lastName (name)
- myAccount → name (name)
- myAccount → lastName (name)
- nameSpecialValidationRules → name (name)
Error: common (myValidatorRules)
- hasText Please, fill the field
- dateFormat Please, fill the field with a valid date
Used by Rules
- myValidatorRules → name (common.hasText)
- myValidatorRules → hasText (common.hasText)
- myValidatorRules → date (common.dateFormat)
- myValidatorRules → date (common.dateFormat)
Error: email (myValidatorRules)
- regex Please, fill the field with a valid e-mail
- equals The email and email confirm are not equals
Used by Rules
- myValidatorRules → email (email.regex)
- myValidatorRules → email (email.regex)
- myValidatorRules → email (email.equals)
Error: phone (myValidatorRules)
- regex Please, fill the field with a valid phone
Used by Rules
- myValidatorRules → phone (phone.regex)
Error: date (myValidatorRules)
- validDate Please, fill the field with a existent date
- validateAge Invalid age, under 18
Used by Rules
- myValidatorRules → date (date.validDate)
- myValidatorRules → date (date.validateAge)
Error: cpf (myValidatorRules)
- cpf Plase, fill the field with a valid CPF
Used by Rules
- myValidatorRules → cpf (cpf.cpf)
Error: name (myValidatorRules)
- nameSpecialValidation Please, fill the field following fields: name, email and cellphone
Used by Rules
- nameSpecialValidationRules → name (name.nameSpecialValidation)