<commit_before>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */
foam.CLASS({
  package: 'foam.nanos.auth',
  name: 'Phone',

  documentation: 'Phone number information.',

  messages: [
    {
      name: 'INVALID_NUMBER',
      message: 'Invalid phone number.'
    }
  ],

  constants: [
    {
      name: 'PHONE_REGEX',
      factory: function() {
        return /^(?:\+?1[-.●]?)?\(?([0-9]{3})\)?[-.●]?([0-9]{3})[-.●]?([0-9]{4})$/
      }
    }
  ],

  properties: [
    {
      class: 'PhoneNumber',
      name: 'number',
      label: '',
      required: true,
      validateObj: function (number) {
        if ( ! this.PHONE_REGEX.test(number) ) {
          return this.INVALID_NUMBER;
        }
      },
      javaValidateObj: `
        String number = ((Phone) obj).getNumber();
        if ( foam.util.SafetyUtil.isEmpty(number) ) {
          throw new IllegalStateException(Phone.INVALID_NUMBER);
        }
      `
    },
    {
      class: 'Boolean',<commit_msg>Use ValidationPredicate for Phone.<commit_after>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */
foam.CLASS({
  package: 'foam.nanos.auth',
  name: 'Phone',

  documentation: 'Phone number information.',

  properties: [
    {
      class: 'PhoneNumber',
      name: 'number',
      label: '',
      validationPredicates: [
        {
          args: ['number'],
          predicate: {
            class: 'foam.mlang.predicate.RegExp',
            arg1: {
              class: 'foam.mlang.FObjectPropertyExpr',
              property: 'number'
            },
            regExp: /^(?:\+?1[-.●]?)?\(?([0-9]{3})\)?[-.●]?([0-9]{3})[-.●]?([0-9]{4})$/
          },
          errorString: 'Invalid phone number.'
        }
      ],
      // TODO: Remove javaValidateObj
      javaValidateObj: `
        String number = ((Phone) obj).getNumber();
        if ( foam.util.SafetyUtil.isEmpty(number) ) {
          throw new IllegalStateException(Phone.INVALID_NUMBER);
        }
      `
    },
    {
      class: 'Boolean',
{'fraction_non_alphanumeric': 0.17989666510098637, 'fraction_numerical': 0.015500234852043212, 'mean_word_length': 1.9915730337078652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5368542', 'n_tokens_mistral': 702, 'n_tokens_neox': 688, 'n_words': 121}