Skip to content

Conversation

erfanium
Copy link
Collaborator

@erfanium erfanium commented Mar 11, 2020

Sometime I need use a same validation rule in some places, aliases (or whatever name is better) are great for this case.
For example, I define an alias for my username validation rule:

v.alias('username', {
   type: 'string',
   min: 4,
   max: 30
   regex: ...
  ....
})

Then, I can use this alias everywhere I want:

v.compile({
   firstName: 'string',
   email: 'email',
   username: 'username'  // using alias 
}) 

also, extending aliases!

v.compile({
   firstName: 'string',
   email: 'email',
   username: {
      type: 'username',
      optional: true,
      max: 60
   }
}) 

@coveralls
Copy link

coveralls commented Mar 11, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling e300c40 on erfanium:master into ddd8ec2 on icebob:master.

Copy link
Owner

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Please don't push code style changes because hard to check the relevant changes.

@erfanium
Copy link
Collaborator Author

@icebob
Fixed.
To avoid this problem, it's better to use Prettier , etc...

@erfanium erfanium requested a review from icebob March 14, 2020 20:25
@erfanium erfanium requested a review from icebob March 14, 2020 20:53
@icebob icebob merged commit d1edb33 into icebob:master Mar 14, 2020
@icebob
Copy link
Owner

icebob commented Mar 14, 2020

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants