A-letubby
A-letubby

Reputation: 9132

How to use Validations in sails.js?

I want to use 'ip' validation but I tried something like

attributes: {
  type: 'string',
  ip: true
}

but it always refuse when I gives 192.168.2.1 or any other ip.

I know there is a list of available in this page http://sailsjs.org/#!documentation/models

However, they don't explain how to use each one. If anyone knows other good document or any rules on usage, please!

Upvotes: 0

Views: 149

Answers (1)

sgress454
sgress454

Reputation: 24948

First you need to give your attribute a name. Then to use the IP validator, set the type of the attribute to ip:

attributes: {
  ipAddr: {
    type: 'ip'
  }
}

Upvotes: 1

Related Questions