Skip to content

Using other fields values in a custom validator #847

Open
@donalmurtagh

Description

@donalmurtagh

The docs include this example that shows how to write a custom validator for a field:

[
  {
    key: 'name',
    validationMessage: {
      'noBob': 'Bob is not OK! You here me?'
    },
    $validators: {
      noBob: function(value) {
        if (angular.isString(value) && value.indexOf('Bob') !== -1) {
          return false;
        }
        return true
      }
    }
  }
]

Is it somehow possible to use other field values in a custom validator? For example, if we want to apply the validation above only if model.gender == 'MALE'?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions