Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get order of operations the user has entered #7

Open
msaron opened this issue Jan 10, 2017 · 0 comments
Open

Get order of operations the user has entered #7

msaron opened this issue Jan 10, 2017 · 0 comments

Comments

@msaron
Copy link

msaron commented Jan 10, 2017

Is it possible to get the order of operations the user has entered? I am trying to port the hapijs/Joi object schema validation to Go. Here is how the Joi library in NodeJS is used. Joi modifies and returns the final value as it is being validated; for example, if it says the value has to be in uppercase, the input value is uppercased and if a default value is specified, Joi sets the default value if there is none specified. In NodeJS, I use it for everything including URL query values, form input values, outgoing data, etc. I decided to attempt to port this as I could not find a good solution already available in Go.


var schema = Joi.object().keys({
    username: Joi.string().alphanum().min(3).max(30).required(),
    password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/),
    access_token: [Joi.string(), Joi.number()],
    birthyear: Joi.number().integer().min(1900).max(2013),
    email: Joi.string().email()
}).with('username', 'birthyear').without('password', 'access_token');

Joi.validate({ username: 'abc', birthyear: 1994 }, schema, function (err, value) { });  // err === null -> valid
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

No branches or pull requests

1 participant