How to use the is_js.propertyDefined function in is_js

To help you get started, we’ve selected a few is_js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Albert-Gao / veasy / src / helpers.js View on Github external
export function getFieldsValue(schema, state, mustOK = true) {
  const fieldNames = Object.keys(schema);
  let result = {};

  if (is.propertyDefined(schema, 'collectValues')) {
    result = {
      ...getCollectValues(schema.collectValues, state)
    };
  }

  fieldNames.forEach(name => {
    if (is.not.propertyDefined(state, name)) {
      // eslint-disable-next-line no-console
      console.warn(`[veasy]: No ${name} found in state.`);
      return;
    }
    const fieldState = state[name];
    if (mustOK && fieldState.status !== FieldStatus.ok) return;
    result[name] = fieldState.value;
  });
github Albert-Gao / veasy / src / VeasyForm.jsx View on Github external
isRegisteredComponent = child => {
    // Skip HTML element
    if (is.string(child.type)) return false;

    if (!is.propertyDefined(child.props, 'name')) return false;

    const childName = child.props.name;
    const names = Object.keys(this.props.schema);
    return names.includes(childName);
  };
github faressoft / flowa / index.js View on Github external
Flowa.prototype._indexTasks = function(task, taskName, runnerType, depth, parentTaskName) {

  // The current property is not a task
  if (is.not.function(task) && is.not.json(task)) {
    return;
  }

  // Duplicated task name
  if (is.propertyDefined(this._tasks, taskName)) {
    throw new Error('The task ' + taskName + ' is duplicated. Tasks names should be unique');
  }

  // Invalid runner type
  if (is.not.propertyDefined(this._runners, runnerType)) {
    throw new Error('The type ' + runnerType + ' is not a valid runner type');
  }

  this._tasks[taskName] = task;
  this._tasksDepths[taskName] = depth;
  this._tasksParents[taskName] = parentTaskName;
  this._tasksRunnersTypes[taskName] = runnerType;

  // Is a compound task
  if (this._isCompoundTask(taskName)) {
github Albert-Gao / veasy / src / helpers.js View on Github external
Object.keys(schema).forEach(ruleInSchema => {
    if (is.propertyDefined(matcher, ruleInSchema)) {
      ruleRunner(
        ruleInSchema, 
        matcher[ruleInSchema], 
        fieldName, 
        fieldState.value, 
        schema
      );
    }
    else if (ruleInSchema === 'beforeValidation') {
      fieldState.value = handleBeforeValidation(
        fieldState.value, 
        schema.beforeValidation
      );
    }
    // TODO: Do something when the rule is not match
    // else if (ruleInSchema !== 'default') {
github Albert-Gao / veasy / src / helpers.js View on Github external
schemaItems.forEach(name => {
    if (is.propertyDefined(userState, name)) {
      initialState[name] = {
        ...initialState[name],
        ...userState[name]
      };
    }
  });
github Albert-Gao / veasy / src / helpers.js View on Github external
export function createInitialValue(schema) {
  if (is.propertyDefined(schema, 'default')) {
    return schema.default;
  } else if (is.propertyDefined(schema, 'min')) {
    return schema.min;
  }
  return '';
}
github Albert-Gao / veasy / src / helpers.js View on Github external
export function createInitialValue(schema) {
  if (is.propertyDefined(schema, 'default')) {
    return schema.default;
  } else if (is.propertyDefined(schema, 'min')) {
    return schema.min;
  }
  return '';
}