Valid 88

Client Validation
Valid88 is a framework for validating user input on the front and back end from a single configuration file.

So what are the benefits?

  • - Easy to configure field validation
  • - Executed on the client and server
  • - Helps secure against rest client attacks
Valid 88 Sample

Here's the configuration for validating this form...
{
  "validationsets":[
    {"name":"userdetails", "fields":[
      {"name":"firstname", "field":"user.firstname", "type":"string", "validations":[
        {"name":"standardname", "composite":true}
      ]},
      {"name":"lastname", "field":"user.lastname", "type":"string", "validations":[
        {"name":"standardname", "composite":true}
      ]},
      {"name":"email", "field":"user.email", "type":"string", "validations":[
        {"name":"email"}
      ]},
      {"name":"dob", "field":"user.dob", "type":"date", "validations":[
        {"name":"mandatory", "value":true},
        {"name":"date", "variants":
          [
            {"type":"atleast", "value":18, "datepart":"years"},
            {"type":"atmost", "value":80, "datepart":"years"}
          ]
        }
      ]}
    ]}
  ],

  "compositevalidations":[
    {"name": "standardname", "type":"string", "validations":[
      {"name":"mandatory", "value":true},
      {"name":"regex", "value":{"types":["alpha","latin"]}, "additionalchars":"' "},
      {"name":"maxlength", "length":24}
    ]}
  ]
}

There are four field validations configured here. The firstname and lastname fields both use the composite validation standardname which has mandatory, regex and maxlength validations. The email address field uses an email validator. The dob validation has a mandatory validation and and date validation which checks that the date gives an age of between 18 and 80 years.

To apply they validations on the client just load the configuration above into a Valid88 object and then pass the data to be validated.

var result = v88.validateInput('userdetails', {user:form.values});
setValues({...form, errors: result.errors});


Our configuration can contain more than one validation set, so we pass the name of the validation set to be used in the first parameter. The second parameter is simply the object containing the data.
Server Validation
Any web developer knows how important it is not to rely solely on client side validation. Client requests can easily be inspected and replicated with invalid data as part of an attack. One of the main advantages of Valid88 is that the same validations can be applied on the client and the server by using the very same configuration files.

Using the configuration files above, the request JSON below can be validated in the same way on the server.