src/validation/property-validator-schema.js
function makeTypeConstraintsSchema(typeName) {
  const allTypeConstraints = typeSpecificConstraintSchemas();
  const constraints = Object.assign({ }, universalConstraintSchemas(typeEqualitySchemas[typeName]), allTypeConstraints[typeName]);

  return joi.object().keys(constraints)
    // Prevent the use of more than one constraint from the "required value" category
    .without('required', [ 'mustNotBeMissing', 'mustNotBeNull' ])
    .without('mustNotBeMissing', [ 'required', 'mustNotBeNull' ])
    .without('mustNotBeNull', [ 'required', 'mustNotBeMissing' ])

    // Prevent the use of more than one constraint from the "equality" category
    .without('mustEqual', [ 'mustEqualStrict', 'mustEqualIgnoreCase' ])
    .without('mustEqualStrict', [ 'mustEqual', 'mustEqualIgnoreCase' ])
    .without('mustEqualIgnoreCase', [ 'mustEqual', 'mustEqualStrict' ])

    // Prevent the use of more than one constraint from the "minimum value" category
    .without('minimumValue', [ 'minimumValueExclusive', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ])
    .without('minimumValueExclusive', [ 'minimumValue', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ])

    // Prevent the use of more than one constraint from the "maximum value" category
    .without('maximumValue', [ 'maximumValueExclusive', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ])
    .without('maximumValueExclusive', [ 'maximumValue', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ])

    // Prevent the use of more than one constraint from the "immutability" category
    .without('immutable', [ 'immutableStrict', 'immutableWhenSet', 'immutableWhenSetStrict' ])
    .without('immutableStrict', [ 'immutable', 'immutableWhenSet', 'immutableWhenSetStrict' ])
    .without('immutableWhenSet', [ 'immutable', 'immutableStrict', 'immutableWhenSetStrict' ])
    .without('immutableWhenSetStrict', [ 'immutable', 'immutableStrict', 'immutableWhenSet' ])

    // Prevent the use of more than one constraint from the "skip validation" category
    .without('skipValidationWhenValueUnchanged', [ 'skipValidationWhenValueUnchangedStrict' ]);
}
function makeTypeConstraintsSchema(typeName) {
  const allTypeConstraints = typeSpecificConstraintSchemas();
  const constraints = Object.assign({ }, universalConstraintSchemas(typeEqualitySchemas[typeName]), allTypeConstraints[typeName]);

  return joi.object().keys(constraints)
    // Prevent the use of more than one constraint from the "required value" category
    .without('required', [ 'mustNotBeMissing', 'mustNotBeNull' ])
    .without('mustNotBeMissing', [ 'required', 'mustNotBeNull' ])
    .without('mustNotBeNull', [ 'required', 'mustNotBeMissing' ])

    // Prevent the use of more than one constraint from the "equality" category
    .without('mustEqual', [ 'mustEqualStrict', 'mustEqualIgnoreCase' ])
    .without('mustEqualStrict', [ 'mustEqual', 'mustEqualIgnoreCase' ])
    .without('mustEqualIgnoreCase', [ 'mustEqual', 'mustEqualStrict' ])

    // Prevent the use of more than one constraint from the "minimum value" category
    .without('minimumValue', [ 'minimumValueExclusive', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ])
    .without('minimumValueExclusive', [ 'minimumValue', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ])

    // Prevent the use of more than one constraint from the "maximum value" category
    .without('maximumValue', [ 'maximumValueExclusive', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ])
    .without('maximumValueExclusive', [ 'maximumValue', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ])

    // Prevent the use of more than one constraint from the "immutability" category
    .without('immutable', [ 'immutableStrict', 'immutableWhenSet', 'immutableWhenSetStrict' ])
    .without('immutableStrict', [ 'immutable', 'immutableWhenSet', 'immutableWhenSetStrict' ])
    .without('immutableWhenSet', [ 'immutable', 'immutableStrict', 'immutableWhenSetStrict' ])
    .without('immutableWhenSetStrict', [ 'immutable', 'immutableStrict', 'immutableWhenSet' ])

    // Prevent the use of more than one constraint from the "skip validation" category
    .without('skipValidationWhenValueUnchanged', [ 'skipValidationWhenValueUnchangedStrict' ]);
}
function makeTypeConstraintsSchema ( typeName ) { const allTypeConstraints = typeSpecificConstraintSchemas ( ) ; const constraints = Object . assign ( { } , universalConstraintSchemas ( typeEqualitySchemas [ typeName ] ) , allTypeConstraints [ typeName ] ) ; return joi . object ( ) . keys ( constraints ) // Prevent the use of more than one constraint from the "required value" category . without ( 'required' , [ 'mustNotBeMissing' , 'mustNotBeNull' ] ) . without ( 'mustNotBeMissing' , [ 'required' , 'mustNotBeNull' ] ) . without ( 'mustNotBeNull' , [ 'required' , 'mustNotBeMissing' ] ) // Prevent the use of more than one constraint from the "equality" category . without ( 'mustEqual' , [ 'mustEqualStrict' , 'mustEqualIgnoreCase' ] ) . without ( 'mustEqualStrict' , [ 'mustEqual' , 'mustEqualIgnoreCase' ] ) . without ( 'mustEqualIgnoreCase' , [ 'mustEqual' , 'mustEqualStrict' ] ) // Prevent the use of more than one constraint from the "minimum value" category . without ( 'minimumValue' , [ 'minimumValueExclusive' , 'mustEqual' , 'mustEqualStrict' , 'mustEqualIgnoreCase' ] ) . without ( 'minimumValueExclusive' , [ 'minimumValue' , 'mustEqual' , 'mustEqualStrict' , 'mustEqualIgnoreCase' ] ) // Prevent the use of more than one constraint from the "maximum value" category . without ( 'maximumValue' , [ 'maximumValueExclusive' , 'mustEqualStrict' , 'mustEqual' , 'mustEqualIgnoreCase' ] ) . without ( 'maximumValueExclusive' , [ 'maximumValue' , 'mustEqualStrict' , 'mustEqual' , 'mustEqualIgnoreCase' ] ) // Prevent the use of more than one constraint from the "immutability" category . without ( 'immutable' , [ 'immutableStrict' , 'immutableWhenSet' , 'immutableWhenSetStrict' ] ) . without ( 'immutableStrict' , [ 'immutable' , 'immutableWhenSet' , 'immutableWhenSetStrict' ] ) . without ( 'immutableWhenSet' , [ 'immutable' , 'immutableStrict' , 'immutableWhenSetStrict' ] ) . without ( 'immutableWhenSetStrict' , [ 'immutable' , 'immutableStrict' , 'immutableWhenSet' ] ) // Prevent the use of more than one constraint from the "skip validation" category . without ( 'skipValidationWhenValueUnchanged' , [ 'skipValidationWhenValueUnchangedStrict' ] ) ; }
Creates a validation schema for the constraints of the specified type
Creates a validation schema for the constraints of the specified type