Skip to content

Get order of operations the user has entered #7

Description

@msaron

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions