{"size": 741, "ext": "js", "max_stars_repo_path": "ui/src/components/mobileservices/validator/constraints/FieldValueConstraint.js", "max_stars_repo_name": "evanshortiss/mobile-developer-console", "max_stars_repo_stars_event_min_datetime": "2018-12-11T21:36:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-28T14:12:11.000Z", "max_issues_repo_path": "ui/src/components/mobileservices/validator/constraints/FieldValueConstraint.js", "max_issues_repo_name": "evanshortiss/mobile-developer-console", "max_issues_repo_issues_event_min_datetime": "2018-09-27T20:52:15.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-21T14:13:42.000Z", "max_forks_repo_path": "ui/src/components/mobileservices/validator/constraints/FieldValueConstraint.js", "max_forks_repo_name": "evanshortiss/mobile-developer-console", "max_forks_repo_forks_event_min_datetime": "2018-10-01T14:43:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-08T11:22:39.000Z"}
{"max_stars_count": 8, "max_issues_count": 185, "max_forks_count": 18, "avg_line_length": 28.5, "max_line_length": 95, "alphanum_fraction": 0.6599190283}
/**
 * This constraint is used to constraint the ruleset to the value of a given field in the form.
 * The configuration to be put into the JSON file for this rule must be as follows:
 * {
 *   "type": "FIELD_VALUE",  // this must be exactly 'FIELD_VALUE'
 *   "name": "field_name",   // the name of the field to be checked
 *   "value": "value"        // the value to be checked
 * }
 */
export class FieldValueConstraint {
  constructor(config) {
    this.config = config;
  }

  /**
   * Returns true if the configured field has the configured value into formData
   * @param formData
   * @returns {boolean}
   */
  check(formData) {
    return formData[this.config.name] === this.config.value;
  }
}

export const NAME = 'FIELD_VALUE';
