Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validator: value => {
return value % this.multipleOf === 0
? ''
: getMessage('schema.multipleOf')
}
})
validator: value => {
return Object.keys(value || {}).length >= this.minProperties
? ''
: getMessage('schema.minProperties')
}
})
validator: value => {
return Object.keys(value || {}).length <= this.maxProperties
? ''
: getMessage('schema.maxProperties')
}
})
validator: value => {
return value === this.const ? '' : getMessage('schema.const')
}
})
validator: value => {
value = toArr(value)
return value.some((item: any, index: number) => {
for (let start = index; start < value.length; start++) {
if (isEqual(value[start], item)) {
return false
}
}
})
? getMessage('schema.uniqueItems')
: ''
}
})
this.rafValidateId = raf(() => {
if (this.destructed) {
return resolve()
}
return runValidation(
values || this.state.values,
this.fields,
forceUpdate
)
.then(response => {
const lastValid = this.state.valid
const newErrors = reduce(
response,
(buf, { name, errors }) => {
if (!errors.length) {
return buf
} else {
return buf.concat({ name, errors })
}
},
[]
)
}
if (isFormState(target)) {
return state.hasChanged(path)
} else if (isFieldState(target) || isVirtualFieldState(target)) {
const node = graph.get(target.path)
return node && node.hasChanged(path)
} else {
throw new Error(
'Illegal parameter,You must pass the correct state object(FormState/FieldState/VirtualFieldState).'
)
}
}
const state = new FormState(options)
const validator = new FormValidator({
...options,
matchStrategy
})
const graph = new FormGraph({
matchStrategy
})
const applyWithScheduler = scheduler(options.validateConcurrentTimeMS)
const formApi = {
submit,
reset,
hasChanged,
clearErrors,
validate,
setFormState,
getFormState,
setFieldState,
submittingTask: undefined
}
heart.publish(LifeCycleTypes.ON_FORM_WILL_INIT, state)
state.subscription = {
notify: onFormChange
}
graph.appendNode('', state)
state.setState((state: IFormState) => {
state.initialized = true
})
graph.subscribe(onGraphChange)
return formApi
}
export const registerValidationFormats = FormValidator.registerFormats
export const registerValidationRules = FormValidator.registerRules
export const registerValidationMTEngine = FormValidator.registerMTEngine
export {
setValidationLanguage,
setValidationLocale,
FormPath,
FormPathPattern,
FormGraph
}
export default createForm
notify: onFormChange
}
graph.appendNode('', state)
state.setState((state: IFormState) => {
state.initialized = true
})
graph.subscribe(onGraphChange)
return formApi
}
export const registerValidationFormats = FormValidator.registerFormats
export const registerValidationRules = FormValidator.registerRules
export const registerValidationMTEngine = FormValidator.registerMTEngine
export {
setValidationLanguage,
setValidationLocale,
FormPath,
FormPathPattern,
FormGraph
}
export default createForm
heart.publish(LifeCycleTypes.ON_FORM_WILL_INIT, state)
state.subscription = {
notify: onFormChange
}
graph.appendNode('', state)
state.setState((state: IFormState) => {
state.initialized = true
})
graph.subscribe(onGraphChange)
return formApi
}
export const registerValidationFormats = FormValidator.registerFormats
export const registerValidationRules = FormValidator.registerRules
export const registerValidationMTEngine = FormValidator.registerMTEngine
export {
setValidationLanguage,
setValidationLocale,
FormPath,
FormPathPattern,
FormGraph
}
export default createForm